package com.csu54sher.basereservation.handler;


import com.csu54sher.basereservation.common.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    /**
     * 捕获业务异常
     * @param ex
     * @return
     */
    @ExceptionHandler
    public ApiResponse exceptionHandler(RuntimeException ex){
        log.error("异常信息：{}", ex.getMessage());
        return ApiResponse.error(500,ex.getMessage());
    }
}
